#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

static gboolean is_fullscreen = FALSE; // 新增状态变量

static void destroy_handler(GtkWidget *widget, gpointer data) {
    gtk_main_quit();
}

static gboolean on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data) {
    if (event->keyval == GDK_KEY_F11) {
        // 通过状态变量切换
        if (is_fullscreen) {
            gtk_window_unfullscreen(GTK_WINDOW(widget));
            is_fullscreen = FALSE;
        } else {
            gtk_window_fullscreen(GTK_WINDOW(widget));
            is_fullscreen = TRUE;
        }
        return TRUE;
    }
    return FALSE;
}

int main(int argc, char *argv[]) {
    GtkWidget *window;

    gtk_init(&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_title(GTK_WINDOW(window), "音乐");
    gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);

    g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);
    g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
    g_signal_connect(window, "destroy", G_CALLBACK(destroy_handler), NULL);

    gtk_widget_show_all(window);
    gtk_main();

    return 0;
}
